import request from "@/utils/request";

const api_name = "/forum";

export default {
  find0BoardEssay(theme, findType) {
    return request({
      url: `${api_name}/find0BoardEssay`,
      method: "get",
      params: {
        theme: theme,
        findType: findType,
      },
    });
  },
  find1BoardEssay(pageNum, pageSize, theme, findType) {
    return request({
      url: `${api_name}/find1BoardEssay`,
      method: "get",
      params: {
        pageNum: pageNum,
        pageSize: pageSize,
        theme: theme,
        findType: findType,
      },
    });
  },
  addArticle(article) {
    return request({
      url: `${api_name}/add`,
      method: "post",
      params: {
        attachmentUrls: article.attachmentUrls,
        pBoardId: article.pBoardId,
        title: article.title,
        content: article.content,
        summary: article.summary,
        tag: article.tag,
        questionType: article.questionType,
        answer: article.answer,
        attachmentType: article.attachmentType,
        deadLine: article.deadLine,
      },
      // paramsSerializer: function (param) {
      //   const myParam = param.attachmentUrls.map((_) => `tag=${_}`).join("&");
      //   return myParam;
      // },
    });
  },
  getArticleDetail(articleId, forLike) {
    return request({
      url: `${api_name}/getArticleDetail`,
      method: "get",
      params: {
        articleId: articleId,
        forLike: forLike,
      },
    });
  },
  doLike(articleId) {
    return request({
      url: `${api_name}/doLike`,
      method: "post",
      params: {
        articleId: articleId,
      },
    });
  },
};
